/**
* @description: 754. 到达终点数字
* @author hewei
* @date 2022/8/22 14:57
* @version 1.0
*/

public class ReachNumber {

    public static void main(String[] args) {
        ReachNumber reachNumber = new ReachNumber();
        System.out.println(reachNumber.reachNumber(-1000000000));
    }

    public int reachNumber(int target) {
        int k = 0;
        target = Math.abs(target);
        while (target > 0) target -= ++k;
        if (Math.abs(target) % 2 == 0) return k;
        if ((Math.abs(target) + k + 1) % 2 == 0) return k + 1;
        return k + 2;
    }
}
